@@ -138,5 +138,5 @@ span.not-applicable:after {
|
||
| 138 | 138 |
// Disabled |
| 139 | 139 |
|
| 140 | 140 |
.agent-disabled {
|
| 141 |
- text-decoration:line-through; |
|
| 141 |
+ opacity: 0.5; |
|
| 142 | 142 |
} |
@@ -30,38 +30,6 @@ class AgentsController < ApplicationController |
||
| 30 | 30 |
end |
| 31 | 31 |
end |
| 32 | 32 |
|
| 33 |
- def disable |
|
| 34 |
- agent = current_user.agents.find(params[:id]) |
|
| 35 |
- |
|
| 36 |
- # save_successful = false |
|
| 37 |
- |
|
| 38 |
- # Enable/Disable the agent |
|
| 39 |
- if params[:disable] == "true" |
|
| 40 |
- agent.disabled = true |
|
| 41 |
- save_successful = agent.save |
|
| 42 |
- message = "Agent '#{agent.name}' disabled"
|
|
| 43 |
- elsif params[:disable] == "false" |
|
| 44 |
- agent.disabled = false |
|
| 45 |
- save_successful = agent.save |
|
| 46 |
- message = "Agent '#{agent.name}' enabled"
|
|
| 47 |
- end |
|
| 48 |
- |
|
| 49 |
- # Handle save errors |
|
| 50 |
- if save_successful != true |
|
| 51 |
- agent_status = "enabled" |
|
| 52 |
- if agent.disabled? |
|
| 53 |
- agent_status = "disabled" |
|
| 54 |
- end |
|
| 55 |
- message = "Something went wrong. Agent '#{agent.name}' is still #{agent_status} #{save_successful}"
|
|
| 56 |
- end |
|
| 57 |
- |
|
| 58 |
- if params[:return] == "show" |
|
| 59 |
- redirect_to agent_path(agent), notice: message |
|
| 60 |
- else |
|
| 61 |
- redirect_to agents_path, notice: message |
|
| 62 |
- end |
|
| 63 |
- end |
|
| 64 |
- |
|
| 65 | 33 |
def type_details |
| 66 | 34 |
agent = Agent.build_for_type(params[:type], current_user, {})
|
| 67 | 35 |
render :json => {
|
@@ -145,7 +113,13 @@ class AgentsController < ApplicationController |
||
| 145 | 113 |
|
| 146 | 114 |
respond_to do |format| |
| 147 | 115 |
if @agent.update_attributes(params[:agent]) |
| 148 |
- format.html { redirect_to agents_path, notice: 'Your Agent was successfully updated.' }
|
|
| 116 |
+ format.html {
|
|
| 117 |
+ if params[:return] == "show" |
|
| 118 |
+ redirect_to agent_path(@agent), notice: 'Your Agent was successfully updated.' |
|
| 119 |
+ else |
|
| 120 |
+ redirect_to agents_path, notice: 'Your Agent was successfully updated.' |
|
| 121 |
+ end |
|
| 122 |
+ } |
|
| 149 | 123 |
format.json { head :no_content }
|
| 150 | 124 |
else |
| 151 | 125 |
format.html { render action: "edit" }
|
@@ -37,13 +37,6 @@ |
||
| 37 | 37 |
</div> |
| 38 | 38 |
|
| 39 | 39 |
<div class="control-group"> |
| 40 |
- <%= f.label :disable_agent, :class => 'control-label' %> |
|
| 41 |
- <div class="controls disabled-region"> |
|
| 42 |
- <%= f.check_box :disabled %> |
|
| 43 |
- </div> |
|
| 44 |
- </div> |
|
| 45 |
- |
|
| 46 |
- <div class="control-group"> |
|
| 47 | 40 |
<%= f.label :schedule, :class => 'control-label' %> |
| 48 | 41 |
<div class="controls schedule-region" data-can-be-scheduled="<%= @agent.can_be_scheduled? %>"> |
| 49 | 42 |
<%= f.select :schedule, options_for_select(Agent::SCHEDULES.map {|s| [s.humanize.titleize, s] }, @agent.schedule), {}, :class => 'span4' %>
|
@@ -19,7 +19,7 @@ |
||
| 19 | 19 |
|
| 20 | 20 |
<% @agents.each do |agent| %> |
| 21 | 21 |
<% if agent.disabled? %> |
| 22 |
- <tr class='agent-disabled'> <!-- TODO: Change this to an agent-disabled class --> |
|
| 22 |
+ <tr class='agent-disabled'> |
|
| 23 | 23 |
<% else %> |
| 24 | 24 |
<tr> |
| 25 | 25 |
<% end %> |
@@ -71,9 +71,9 @@ |
||
| 71 | 71 |
<%= link_to 'Edit', edit_agent_path(agent), class: "btn btn-mini btn-primary" %> |
| 72 | 72 |
|
| 73 | 73 |
<% if agent.disabled? %> |
| 74 |
- <%= link_to 'Enable', disable_agent_path(agent, :disable => "false", :return => "index"), method: :post, class: "btn btn-mini btn-success" %> |
|
| 74 |
+ <%= link_to "Enable", agent_path(agent, :agent => { :disabled => false }), :method => :put, class: "btn btn-mini btn-success"%>
|
|
| 75 | 75 |
<% else %> |
| 76 |
- <%= link_to 'Disable', disable_agent_path(agent, :disable => "true", :return => "index"), method: :post, class: "btn btn-mini btn-warning" %> |
|
| 76 |
+ <%= link_to "Disable", agent_path(agent, :agent => { :disabled => true }), :method => :put, class: "btn btn-mini btn-warning"%>
|
|
| 77 | 77 |
<% end %> |
| 78 | 78 |
|
| 79 | 79 |
<%= link_to 'Delete', agent_path(agent), method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-mini btn-danger" %>
|
@@ -34,9 +34,9 @@ |
||
| 34 | 34 |
|
| 35 | 35 |
<li> |
| 36 | 36 |
<% if !@agent.disabled? %> |
| 37 |
- <%= link_to '<i class="icon-pause"></i> Disable agent'.html_safe, disable_agent_path(@agent, :disable => "true", :return => "show"), method: :post %> |
|
| 37 |
+ <%= link_to '<i class="icon-pause"></i> Disable agent'.html_safe, agent_path(@agent, :agent => { :disabled => true }, :return => "show"), :method => :put %>
|
|
| 38 | 38 |
<% else %> |
| 39 |
- <%= link_to '<i class="icon-play"></i> Enable agent'.html_safe, disable_agent_path(@agent, :disable => "false", :return => "show"), method: :post %> |
|
| 39 |
+ <%= link_to '<i class="icon-play"></i> Enable agent'.html_safe, agent_path(@agent, :agent => { :disabled => false }, :return => "show"), :method => :put %>
|
|
| 40 | 40 |
<% end %> |
| 41 | 41 |
</li> |
| 42 | 42 |
|
@@ -2,7 +2,6 @@ Huginn::Application.routes.draw do |
||
| 2 | 2 |
resources :agents do |
| 3 | 3 |
member do |
| 4 | 4 |
post :run |
| 5 |
- post :disable |
|
| 6 | 5 |
post :handle_details_post |
| 7 | 6 |
delete :remove_events |
| 8 | 7 |
end |